<template>
  <div class="app-container">
    <el-row type="flex" align="middle" justify="space-between">
      <el-button size="mini" type="primary" @click="addClass">新建班级</el-button>
      <div class="student">
        待排课学员
        <el-button type="text" @click="handleWaitCourse">
          <span>{{waitCourseNum}}</span>
        </el-button>人/ 课时
      </div>
    </el-row>
    <!-- 所有待排课学员 -->
    <el-dialog
      title="所有待排课学员 "
      :visible.sync="waitCourseNumDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      width="60%"
    >
      <el-table
        :data="waitCourseNumData"
        style="width: 100%;min-height:490px"
        max-height="500"
        border
        :header-cell-style="{background:global.mainColor}"
      >
        <el-table-column label="头像" width="180">
          <template slot-scope="scope">
            <el-image style="width:100px" :src="scope.row.avatarStorageUrl"></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column label="性别">
          <template slot-scope="scope">
            <span>{{scope.row.gender === 1 ? '男' : '女'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="年龄">
          <template slot-scope="scope">{{ ageFormatter(scope.row.birthday||'1')}}</template>
        </el-table-column>
        <el-table-column prop="phone" label="联系方式"></el-table-column>
        <el-table-column prop="courseStr" label="所属班级"></el-table-column>
      </el-table>
      <div style="display:flex;justify-content:center">
        <pagination
          :hidden="waitCourseNumtotal<=0"
          :total="waitCourseNumtotal"
          :page.sync="waitCourseNumPage"
          :limit.sync="waitCourseNumPageSize"
          @pagination="getWaitScheduledNum"
        />
      </div>
      <span slot="footer">
        <el-button type="primary" @click="waitCourseNumDialog=false">关闭</el-button>
      </span>
    </el-dialog>
    <!-- 待排课或已排课学员 -->
    <el-dialog
      title="待排课和已排课学员 "
      :visible.sync="waitCourseStudentDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="studentAllCourse=[]"
      width="60%"
    >
      <div style="line-height:50px">
        <el-radio-group v-model="scheduleStatus" @change="getGetStudentByStatus">
          <!-- <el-radio :label="0">全部</el-radio> -->
          <el-radio :label="1">待排课</el-radio>
          <el-radio :label="2">已排课</el-radio>
        </el-radio-group>
      </div>
      <el-table
        :data="studentAllCourse"
        style="width: 100%;min-height:490px"
        max-height="500"
        border
        :header-cell-style="{background:global.mainColor}"
      >
        <el-table-column label="头像" width="180">
          <template slot-scope="scope">
            <el-image style="width:100px;height:100px" :src="scope.row.avatarStorageUrl"></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column label="性别">
          <template slot-scope="scope">
            <span>{{scope.row.gender === 1 ? '男' : '女'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="年龄">
          <template slot-scope="scope">{{ ageFormatter(scope.row.birthday||'1')}}</template>
        </el-table-column>
        <el-table-column prop="phone" label="联系方式"></el-table-column>
      </el-table>
      <div style="display:flex;justify-content:center;">
        <pagination
          :hidden="studentAllCourseTotal<=0"
          :total="studentAllCourseTotal"
          :page.sync="studentAllCoursePage"
          :limit.sync="studentAllCoursePageSize"
          @pagination="getGetStudentByStatus"
        />
      </div>
      <span slot="footer">
        <el-button type="primary" @click="waitCourseStudentDialog=false">关闭</el-button>
      </span>
    </el-dialog>
    <el-row>
      <el-col>
        <el-table
          ref="courseTable"
          :data="courseData"
          :border="true"
          height="690"
          highlight-current-row
          :header-cell-style="{background:global.mainColor}"
          style="width: 100%;min-height:689px"
        >
          <el-table-column prop="scheduleCourseName" label="班级名称" align="center" />
          <el-table-column label="课时" align="center">
            <template slot-scope="scope">{{scope.row.lessonTime}}分钟</template>
          </el-table-column>
          <el-table-column prop="teacherName" label="教师" align="center" />
          <el-table-column label="待排课/已排课" align="center">
            <template slot-scope="scope">
              <el-button
                type="text"
                @click="handleWaitCourseStudent(scope.$index, scope.row)"
              >{{scope.row.notScheduled}}/{{scope.row.scheduled}}</el-button>
            </template>
          </el-table-column>
          <el-table-column prop="address" label="操作" align="center" width="300">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="warning"
                @click="handleNamelist(scope.$index, scope.row)"
              >名单</el-button>
              <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
              <el-button
                size="mini"
                type="success"
                @click="handleSchedule(scope.$index, scope.row)"
              >排课</el-button>
              <el-button v-if="scope.row.notScheduled<=0&&scope.row.scheduled<=0" size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <!-- 主表格分页 -->
    <el-row type="flex" justify="center">
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 50, 100, 200]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        :background="true"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-row>
    <!-- 新建班级 -->
    <el-dialog
      title="新建班级 "
      :visible.sync="addClassDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      width="600px"
      @close="JblAddClassForm.resetFields()"
    >
      <el-row type="flex" justify="center" />
      <JblForm
        :ref-name.sync="JblAddClassForm"
        :form.sync="addClassForm"
        :value-data="addClassForm.valueData"
      />
      <span slot="footer">
        <el-button @click="addClassDialog=false">取消</el-button>
        <el-button type="primary" @click="onSubmitAddClassForm">确定</el-button>
      </span>
    </el-dialog>
    <!-- 排课 -->
    <el-dialog
      class="scheduleDialog"
      title="排课 "
      :visible.sync="scheduleDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="cancelSheduleCourseFrom"
      width="700px"
    >
      <el-row type="flex" justify="center" />
      <JblForm
        :ref-name.sync="scheduleCourseFormRef"
        :form.sync="scheduleCourseFrom"
        :value-data="scheduleCourseFrom.valueData"
        @handleEvent="handleEvent"
      >
        <!-- 每周上课节数 -->
        <template v-slot:form-lessonCount>
          <el-row>
            <el-col :span="10">
              <el-select
                size="small"
                v-model="scheduleCourseFrom.valueData.skCount"
                placeholder="请选择节数"
              >
                <el-option
                  v-for="item in scheduleCourseFrom.valueData.lessonCount"
                  :key="item"
                  :label="item"
                  :value="item"
                />
              </el-select>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col v-for="(week,index) in scheduleCourseFrom.valueData.skCount" :key="index">
              <el-select
                style="width:100px"
                size="mini"
                v-model="weekValue[index]"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in weekOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>-
              <el-time-picker
                style="width:170px"
                size="mini"
                v-model.number="dateValue[index]"
                format="HH 点 mm 分"
                value-format="timestamp"
                placeholder="任意时间点"
              />
            </el-col>
          </el-row>
        </template>
        <!-- 上课节数时间 -->
        <template v-slot:form-mjTime>
          <el-row>
            <el-col
              :span="18"
              v-for="(week,index) in scheduleCourseFrom.valueData.lessonCount"
              :key="index"
            >
              <span>第{{index+1}}节:</span>
              <el-date-picker
                style="width:160px"
                size="mini"
                v-model.number="ymValue[index]"
                type="date"
                :pickerOptions="{
                  disabledDate(date) {
                    return date.getTime().valueOf() <= Date.now().valueOf() - 24 * 60 * 60 * 1000
                  }
                }"
                value-format="timestamp"
                placeholder="选择日期"
              ></el-date-picker>-
              <el-time-picker
                size="mini"
                style="width:140px"
                v-model.number="dateValue[index]"
                format="HH 点 mm 分"
                value-format="timestamp"
                placeholder="任意时间点"
              />
            </el-col>
          </el-row>
        </template>
      </JblForm>
      <span slot="footer">
        <el-button @click="scheduleDialog = false">取消</el-button>
        <el-button type="primary" @click="onSubmitJbl">排课预览</el-button>
      </span>
    </el-dialog>
    <!-- 排课预览 -->
    <el-dialog
      title="排课预览 "
      :visible.sync="previewDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="restDatePreview"
      width="600px"
    >
      <el-row type="flex" justify="center">
        <el-table
          border
          :data="previewData"
          :header-cell-style="{background:global.mainColor}"
          style="width: 100%"
        >
          <el-table-column label="节数" width="100">
            <template slot-scope="scope">
              <span>第 {{scope.$index+1}} 节</span>
            </template>
          </el-table-column>
          <el-table-column prop="date" label="时间" />
          <el-table-column label="状态" width="200">
            <template slot-scope="scope">
              <el-tooltip
                class="item"
                effect="dark"
                :content="scope.row.studentName||'正常'"
                placement="top-start"
              >
                <span>{{scope.row.status}}</span>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <span slot="footer">
        <el-button type="primary" @click="confimCourse">确认排课</el-button>
        <el-button @click="restDatePreview">取消</el-button>
      </span>
    </el-dialog>

    <!-- 上课学生 -->
    <el-dialog
      title="上课学生 "
      :visible.sync="upCourseDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="closeUpCourseDialog"
      width="60%"
    >
      <el-row type="flex" align="middle">
        <el-col :span="4">
          <el-button size="mini" type="warning" @click="addStudent">添加学生</el-button>
        </el-col>
        <!-- <el-col :span="2">
          <span>上课学生:</span>
        </el-col>
        <el-col :span="4">
          <el-select size="mini" v-model="upCourse.status" placeholder="请选择">
            <el-option
              v-for="item in upCourseOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-col>-->
        <el-col v-if="upCourse.currentRow.type ===0" :span="2" style="margin-left:10px">
          <span>课程套餐:</span>
        </el-col>
        <el-col v-if="upCourse.currentRow.type ===0" :span="4" class="upCourseRef">
          <el-select
            ref="upCourseRef"
            size="mini"
            v-model="upCourse.setMealId"
            placeholder="请选择"
          >
            <el-option
              v-for="item in upCourseTcOption"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-col>
      </el-row>
      <el-row>
        <el-table
          :data="upCourse.data"
          style="width: 100%;min-height:490px"
          max-height="500"
          border
          :header-cell-style="{background:global.mainColor}"
        >
          <el-table-column label="头像" width="180">
            <template slot-scope="scope">
              <el-image style="width:100px;height:100px" :src="scope.row.avatarStorageUrl"></el-image>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="姓名"></el-table-column>
          <el-table-column label="性别">
            <template slot-scope="scope">
              {{scope.row.gender === 1 ? '男' : '女'}}
            </template>
          </el-table-column>
          <el-table-column label="年龄">
            <template slot-scope="scope">
              {{ageFormatter(scope.row.birthday)}}
            </template>
          </el-table-column>
          <el-table-column prop="phone" label="联系方式"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="warning" size="mini" @click="deleteStudent(scope.row)">移除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <el-row type="flex" justify="center">
        <el-pagination
          :current-page="upCourse.page"
          :page-sizes="this.totalPage"
          :page-size="upCourse.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="upCourse.total"
          :background="true"
          @size-change="handleSizeUpCourseChange"
          @current-change="handleCurrentUpCourseChange"
        />
      </el-row>
      <span slot="footer">
        <el-button type="primary" @click="closeUpCourseDialog">确定</el-button>
      </span>
    </el-dialog>

    <!-- 待排课学生 -->
    <el-dialog
      class="choose"
      title="选择学生"
      :visible.sync="waitCourseDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      @close="closeWaitCourseDialog"
      width="60%"
    >
      <el-row>
        <el-col :span="6">
          <el-input
            size="mini"
            clearable
            placeholder="搜索学生姓名"
            v-model="waitCourse.search"
            @change="handleSearch"
          >
            <el-button slot="append" icon="el-icon-search" @click="handleSearch"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table
        ref="waitCourseTable"
        :data="waitCourse.data"
        border
        fit
        max-height="500"
        style="width: 100%;min-height:499px"
        :header-cell-style="{background:global.mainColor}"
        :row-key="getRowKey"
        @selection-change="handleSelectionChange"
      >
        <el-table-column :reserve-selection="true" type="selection" width="55"></el-table-column>
        <el-table-column label="头像" width="180">
          <template slot-scope="scope">
            <el-image style="width:100px;height:100px" :src="scope.row.avatarStorageUrl"></el-image>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column label="性别">
          <template slot-scope="scope">
            <span>{{scope.row.gender === 1 ? '男' : '女'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="年龄">
          <template slot-scope="scope">{{ ageFormatter(scope.row.birthday||new Date())}}</template>
        </el-table-column>
        <el-table-column prop="phone" label="联系方式"></el-table-column>
        <!-- <el-table-column prop="dyScheduled" label="排课状态" align="center" />
        <el-table-column prop="dyScheduled" label="所属班级" align="center" />-->
      </el-table>
      <el-row type="flex" justify="end" style="margin-top:10px">
        <el-pagination
          :current-page="waitCourse.page"
          :page-sizes="[5, 10, 20, 50]"
          :page-size="waitCourse.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="waitCourse.total"
          :background="true"
          @size-change="handleSizeWaitCourseChange"
          @current-change="handleWaitCourseChange"
        />
      </el-row>
      <span slot="footer">
        <el-button
          type="primary"
          size="small"
          :loading="waitCourse.confimAddStudentLoading"
          @click="confimAddStudent"
        >确定</el-button>
      </span>
    </el-dialog>
    <!-- 编辑 -->
    <el-dialog
      title="编辑班级 "
      :visible.sync="editDialog"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      width="600px"
      @close="JblEditForm.resetFields()"
    >
      <el-row>
        <JblForm
          :ref-name.sync="JblEditForm"
          :form.sync="editForm"
          :value-data="editForm.valueData"
        />
      </el-row>
      <span slot="footer">
        <el-button @click="editDialog=false">取消</el-button>
        <el-button type="primary" @click="onSubmitEditForm">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import JblForm from '@/components/JblForm'
import Pagination from '@/components/Pagination'
import { refreshTablePage } from '@/utils'
import {
  scheduleCourseList,
  getScheduleCourseById,
  addscheduleCourse,
  getStudentIdInPage,
  getByCourseId,
  getStudentOutLis,
  addCourseStudent,
  removeCourseStudent,
  verificationTime,
  generateLesson,
  updateById,
  deleteById,
  getWaitScheduleNumber,
  getWaitScheduled,
  getStudentByStatus
} from '@/api/scheduleCourse'

export default {
  name: 'ScheduleCourseList',
  components: {
    JblForm,
    Pagination
  },
  data() {
    var validateMjTime = (rule, value, callback) => {
      if (this.scheduleCourseFrom.valueData.paikfs === 2 && this.ymValue.length <= 0 && this.dateValue.length <= 0) {
        callback(new Error('请填写上课时间'))
      } else {
        callback()
      }
    }
    return {
      waitCourseNum: '', // 待排课学生数量
      waitCourseNumDialog: false, // 待排课学生
      waitCourseNumData: [], // 待排课学生数据
      waitCourseNumPage: 1,
      waitCourseNumtotal: 0,
      waitCourseNumPageSize: 10,
      waitCourseStudentDialog: false, // 待排课或已排课学生
      scheduleStatus: 1, // 排课状态
      studentAllCourse: [], // 待排课或已排课学生
      studentAllCoursePage: 1,
      studentAllCoursePageSize: 10,
      studentAllCourseTotal: 0,
      totalPage: [10, 50, 100, 200], // 条数/页
      JblForm: {},
      JblAddClassForm: {},
      JblEditForm: {},
      scheduleCourseFormRef: {}, // 排课ref
      addClassDialog: false, // 新建班级
      upCourseDialog: false, //
      scheduleDialog: false, // 排课
      waitCourseDialog: false, // 待排课学生
      previewDialog: false, // 排课预览
      editDialog: false, // 编辑
      qrCodeName: '',
      // 新建班级
      addClassForm: {
        labelWidth: '100px',
        data: [
          {
            type: 'input',
            labelWidth: '80px',
            prop: 'scheduleCourseName',
            label: '班级名称',
            placeholder: '请输入班级名称',
            rules: [
              { required: true, message: '请输入班级名称', trigger: 'blur' },
              {
                min: 1,
                max: 20,
                message: '班级名称不得超过20个字',
                trigger: 'blur'
              }
            ]
          },
          {
            type: 'input',
            labelWidth: '80px',
            prop: 'courseName',
            label: '课程名称',
            placeholder: '请输入课程名称',
            rules: [
              { required: true, message: '请输入班级名称', trigger: 'blur' },
              {
                min: 1,
                max: 20,
                message: '课程名称不得超过20个字',
                trigger: 'change'
              }
            ]
          },
          {
            type: 'input',
            labelWidth: '80px',
            prop: 'setMealName',
            label: '套餐名称',
            placeholder: '请输入套餐名称',
            rules: [
              { required: true, message: '请输入套餐名称', trigger: 'blur' },
              {
                min: 1,
                max: 20,
                message: '长度在 1 到 20 个字符',
                trigger: 'change'
              }
            ]
          },
          {
            type: 'select',
            labelWidth: '80px',
            prop: 'lessonTime',
            label: '每节时长',
            placeholder: '请输入每节时长',
            selectOption: () => {
              return this.lessonTimeOptions
            },
            rules: [
              {
                required: true,
                message: '请输入每节时长多少分钟,例 45',
                trigger: 'blur'
              },
              { type: 'number', message: '每节时长必须为数字值' }
            ]
          },
          {
            type: 'inputNumber',
            labelWidth: '80px',
            prop: 'lessonCount',
            label: '节数',
            placeholder: '请填写课程节数',
            rules: [
              { required: true, message: '请填写课程节数', trigger: 'blur' },
              { type: 'number', message: '课程节数必须为数字值', trigger: 'change' }
            ]
          },
          {
            type: 'input',
            labelWidth: '80px',
            prop: 'teacherName',
            label: '上课老师',
            placeholder: '请输入上课老师',
            rules: [
              { required: true, message: '请输入上课老师', trigger: 'blur' }
            ]
          }
        ],
        valueData: {
          courseName: '',
          lessonTime: null,
          lessonCount: null,
          teacherName: '',
          scheduleCourseName: '',
          type: 1,
          setMealName: ''
        }
      },
      // 编辑
      editForm: {
        labelWidth: '100px',
        data: [
          {
            type: 'input',
            labelWidth: '80px',
            prop: 'scheduleCourseName',
            label: '班级名称',
            placeholder: '请输入班级名称',
            rules: [
              { required: true, message: '请输入班级名称', trigger: 'blur' },
              {
                min: 1,
                max: 20,
                message: '长度在 1 到 20 个字符',
                trigger: 'blur'
              }
            ]
          },
          {
            type: 'input',
            show: () => {
              return this.upCourse.currentRow.type === 1
            },
            labelWidth: '80px',
            prop: 'courseName',
            label: '课程名称',
            placeholder: '请输入课程名称',
            rules: [
              { required: true, message: '请输入班级名称', trigger: 'blur' },
              {
                min: 1,
                max: 20,
                message: '长度在 1 到 20 个字符',
                trigger: 'blur'
              }
            ]
          },
          {
            type: 'input',
            show: () => {
              return this.upCourse.currentRow.type === 1
            },
            labelWidth: '80px',
            prop: 'setMealName',
            label: '套餐名称',
            placeholder: '请输入套餐名称',
            rules: [
              { required: true, message: '请输入套餐名称', trigger: 'blur' },
              {
                min: 1,
                max: 20,
                message: '长度在 1 到 20 个字符',
                trigger: 'blur'
              }
            ]
          },
          {
            type: 'select',
            show: () => {
              return this.upCourse.currentRow.type === 1
            },
            labelWidth: '80px',
            prop: 'lessonTime',
            label: '每节时长',
            placeholder: '请输入每节时长',
            selectOption: () => {
              return this.lessonTimeOptions
            },
            rules: [
              {
                required: true,
                message: '请输入每节时长多少分钟,例 45',
                trigger: 'blur'
              },
              { type: 'number', message: '每节时长必须为数字值' }
            ]
          },
          {
            type: 'inputNumber',
            show: () => {
              return this.upCourse.currentRow.type === 1
            },
            labelWidth: '80px',
            prop: 'lessonCount',
            label: '节数',
            placeholder: '请填写课程节数',
            rules: [
              { required: true, message: '请填写课程节数', trigger: 'blur' },
              { type: 'number', message: '课程节数必须为数字值' }
            ]
          },
          {
            type: 'input',
            show: () => {
              return this.upCourse.currentRow.type === 1
            },
            labelWidth: '80px',
            prop: 'teacherName',
            label: '上课老师',
            placeholder: '请输入上课老师',
            rules: [
              { required: true, message: '请输入上课老师', trigger: 'blur' }
            ]
          }
        ],
        valueData: {
          courseName: '',
          lessonTime: null,
          lessonCount: null,
          teacherName: '',
          scheduleCourseName: '',
          type: 1,
          setMealName: ''
        }
      },
      // 排课
      scheduleCourseFrom: {
        labelWidth: '100px',
        data: [
          {
            type: 'text',
            disabled: true,
            labelWidth: '80px',
            prop: 'courseName',
            label: '课程名称',
            placeholder: '请输入课程名称'
          },
          {
            type: 'select',
            size: 'small',
            show: () => {
              return this.upCourse.currentRow.type === 0
            },
            labelWidth: '80px',
            prop: 'setMealIds',
            label: '套餐名称',
            placeholder: '请选择套餐',
            selectOption: () => {
              return this.upCourseTcOption
            },
            rules: [
              { required: true, message: '请选择套餐', trigger: 'blur' }
            ]
          },
          {
            type: 'text',
            labelWidth: '80px',
            prop: 'teacherName',
            disabled: true,
            label: '上课老师',
            placeholder: '请输入上课老师'
          },
          {
            type: 'text',
            labelWidth: '85px',
            prop: 'kestime',
            label: '课时/节数',
            disabled: true,
            placeholder: '请填写课时时长'
          },
          {
            type: 'radioGroup',
            size: 'small',
            labelWidth: '85px',
            prop: 'paikfs',
            label: '排课方式',
            methods: 'changeRadio',
            radioGroup: () => {
              return [
                {
                  label: '按周排课',
                  value: 1
                },
                {
                  label: '按节排课',
                  value: 2
                }
              ]
            },
            rules: [
              {
                type: 'number',
                required: true,
                message: '排课方式',
                trigger: 'change'
              }
            ]
          },
          {
            type: 'datetime',
            show: () => {
              return this.scheduleCourseFrom.valueData.paikfs === 1
            },
            size: 'small',
            labelWidth: '110px',
            prop: 'startTimes',
            valueFormat: 'timestamp',
            label: '排课起始日期',
            placeholder: '请输入排课起始日期',
            pickerOptions: () => {
              return {
                disabledDate(time) {
                  return time.getTime() < Date.now() - 8.64e7// 如果没有后面的-8.64e7就是不可以选择今天的
                }
              }
            },
            rules: [
              {
                type: 'date',
                required: true,
                message: '请选择排课起始日期',
                trigger: 'change'
              }
            ]
          },
          {
            type: 'slot',
            show: () => {
              return this.scheduleCourseFrom.valueData.paikfs === 1
            },
            labelWidth: '110px',
            prop: 'lessonCount',
            label: '每周上课节数',
            rules: [
              {
                required: true,
                message: '请选择每周上课节数',
                trigger: 'change'
              }
            ]
          },
          {
            type: 'slot',
            show: () => {
              return this.scheduleCourseFrom.valueData.paikfs === 2
            },
            labelWidth: '110px',
            prop: 'mjTime',
            label: '上课时间',
            rules: [
              {
                required: true,
                validator: validateMjTime,
                trigger: 'blur'
              }
            ]
          }
        ],
        valueData: {
          courseName: '',
          scheduleCourseName: '',
          setMealIds: '',
          teacherName: '',
          classHour: '',
          lessonTime: '',
          kestime: '每节30分钟 | 共一节',
          startTimes: '',
          pkStartTime: [], // 排课开始时间
          pkEndTime: [], // 排课结束时间
          lessonCount: 5,
          paikfs: 1,
          skCount: 0,
          weekValue: 1, // 每周排课
          dateValue: '' // 时间
        }
      },
      // 待排课
      waitCourse: {
        page: 1,
        pageSize: 10,
        total: 0,
        studentId: [],
        // 排课课程id
        scheduleCourseId: null,
        confimAddStudentLoading: false, // 确定loading
        search: '',
        data: [],
        // 待排课
        tableColumn: {
          border: true,
          selection: true,
          column: [
            {
              type: 'slot',
              prop: 'avatarStorageUrl',
              label: '头像'
            },
            {
              prop: 'name',
              label: '姓名'
            },
            {
              prop: 'gender',
              label: '性别',
              formatter: row => {
                return row === 1 ? '男' : '女'
              }
            },
            {
              prop: 'birthday',
              label: '年龄'
            },
            {
              prop: 'phone',
              label: '联系方式'
            }
          ]
        }
      },
      weekOptions: [
        {
          label: '每周一',
          value: 0
        },
        {
          label: '每周二',
          value: 1
        },
        {
          label: '每周三',
          value: 2
        },
        {
          label: '每周四',
          value: 3
        },
        {
          label: '每周五',
          value: 4
        },
        {
          label: '每周六',
          value: 5
        },
        {
          label: '每周日',
          value: 6
        }
      ],
      upCourseOptions: [
        // 上课学生
        { label: '已排课', value: 2 },
        { label: '待排课', value: 1 }
      ],
      // 课程套餐集合
      upCourseTcOption: [],
      upCourse: {
        currentRow: {
          type: 1
        },
        page: 1,
        pageSize: 10,
        total: 0,
        setMealId: null, // 套餐id
        scheduleCourseName: null, // 套餐名称
        status: 1, // 学生状态
        data: []
      },
      previewData: [], // 预览数据
      weekValue: [], // 每周排课
      dateValue: [], // 每周时间
      ymValue: [], // 年月时间
      value: 3,
      page: 1,
      pageSize: 10,
      total: 10,
      // 每节时长
      lessonTimeOptions: [
        {
          label: '30分钟',
          value: 30
        },
        {
          label: '40分钟',
          value: 40
        },
        {
          label: '45分钟',
          value: 45
        },
        {
          label: '1小时',
          value: 60
        },
        {
          label: '1小时30分钟',
          value: 90
        },
        {
          label: '2小时',
          value: 120
        },
        {
          label: '2小时30分钟',
          value: 150
        },
        {
          label: '3小时',
          value: 180
        }
      ],
      courseData: []
    }
  },
  computed: {},
  watch: {
    'upCourse.status'(v) {
      this.getStudent(this.upCourse.currentRow)
    },
    'upCourse.setMealId'(v) {
      if (v) {
        this.upCourse.setMealId = v
        this.upCourse.scheduleCourseName = this.upCourseTcOption.find(
          i => i.id === v
        ).name
      }
      this.getStudent(this.upCourse.currentRow)
    },
    // 排课dialog套餐
    'scheduleCourseFrom.valueData.setMealIds'(v) {
      if (!v) return
      const { lessonCount } = this.upCourseTcOption.find(i => i.id === v)
      this.scheduleCourseFrom.valueData.lessonCount = lessonCount
      this.scheduleCourseFrom.valueData.kestime = `每节${this.scheduleCourseFrom.valueData.lessonTime}分钟 | 共 ${lessonCount}节`
    },
    // 排课方式
    'scheduleCourseFrom.valueData.paikfs'(v) {
      this.weekValue = []
      this.dateValue = []
      this.ymValue = []
      this.pkStartTime = []
      this.pkEndTime = []
      this.previewData = []
    },
    'scheduleCourseFrom.valueData.lessonCount'(v) {
      this.weekValue = []
      this.dateValue = []
      this.ymValue = []
    }
  },
  created() {
    this.getCourseList()
  },
  mounted() {},
  methods: {
    handleEvent(methods, data) {
      this[methods](data)
      // console.log('changeRadioGroup')
    },
    changeRadio(data) {
      console.log('dianji', data)
    },
    // 所有待排课学员
    handleWaitCourse() {
      this.waitCourseNumDialog = true
      this.getWaitScheduledNum()
    },
    getWaitScheduledNum() {
      getWaitScheduled({
        currentPage: this.waitCourseNumPage,
        pageSize: this.waitCourseNumPageSize,
        businessId: this.$store.getters.businessId,
        status: 1
      }).then(res => {
        this.waitCourseNumData = res.data.records
        this.waitCourseNumtotal = res.data.total
      })
    },
    // 待排课或已排课学生
    handleWaitCourseStudent(index, row) {
      this.upCourse.currentRow = row
      this.waitCourseStudentDialog = true
      this.getGetStudentByStatus()
    },
    getGetStudentByStatus() {
      getStudentByStatus({
        scheduleCourseId: this.upCourse.currentRow.id,
        scheduleStatus: this.scheduleStatus,
        currentPage: this.studentAllCoursePage,
        pageSize: this.studentAllCoursePageSize
      }).then(res => {
        this.studentAllCourse = res.data ? res.data.records : []
        this.studentAllCourseTotal = res.data ? res.data.total : 0
      })
    },
    // 名单
    async handleNamelist(index, row) {
      TDAPP.onEvent('查看班级名单')
      this.upCourseDialog = true
      this.upCourse.currentRow = row
      this.getStudent(row)
      if (row.type === 0) {
        const res = await getByCourseId({ courseId: row.courseId })
        this.upCourseTcOption = res.data
      }
    },
    // 移除已排课学生
    deleteStudent(row) {
      removeCourseStudent({
        scheduleCourseId: this.upCourse.currentRow.id,
        setMealId: this.upCourse.setMealId,
        businessId: this.$store.getters.businessId,
        studentId: row.id
      }).then(res => {
        this.$message({
          message: '移除成功',
          type: 'success'
        })
        refreshTablePage(
          this.upCourse.page,
          this.upCourse.pageSize,
          this.upCourse.total
        )
        this.getStudent(this.upCourse.currentRow)
      })
    },
    // 查询已排课学生
    async getStudent(row) {
      // 查询学生
      const { data } = await getStudentIdInPage({
        currentPage: this.upCourse.page,
        pageSize: this.upCourse.pageSize,
        scheduleCourseId: row.id,
        businessId: this.$store.getters.businessId,
        setMealId: this.upCourse.setMealId,
        status: this.upCourse.status,
        remove: 0
      })
      if (!data) return
      this.upCourse.total = data.total
      this.upCourse.data = data.records || []
    },

    // 点击添加学生
    addStudent() {
      if (this.upCourse.currentRow.type === 0) {
        if (!this.upCourse.setMealId) {
          this.$message({
            message: '请先选择课程套餐',
            type: 'error'
          })
          this.$refs.upCourseRef.focus()
          return
        }
      }
      this.waitCourseDialog = true
      this.getSecStudent()
    },
    getSecStudent() {
      getStudentOutLis({
        currentPage: this.waitCourse.page,
        pageSize: this.waitCourse.pageSize,
        businessId: this.$store.getters.businessId,
        keyword: this.waitCourse.search,
        // setMealId: this.upCourse.setMealId,
        scheduleCourseId: this.upCourse.currentRow.id,
        remove: 0
      }).then(res => {
        if (!res.data) return
        this.waitCourse.total = res.data.total
        this.waitCourse.data = res.data.records
        // this.waitCourse.data.forEach(i => {
        //   i.birthday = this.ageFormatter(i.birthday)
        // })
        this.$nextTick(() => {
          this.$refs.waitCourseTable.bodyWrapper.scrollTop = 0
        })
      })
    },
    // 添加学生搜索
    handleSearch() {
      this.getSecStudent()
    },
    // 记录当前行id
    getRowKey(row) {
      return row.id
    },
    handleSelectionChange(val) {
      this.waitCourse.studentId = val.map(i => {
        return i.id
      })
    },
    // 关闭上课学生dialog
    closeUpCourseDialog() {
      this.upCourseDialog = false
      this.upCourse.data = []
      this.upCourse.setMealId = null
      this.getCourseList()
    },
    // 确定添加学生
    confimAddStudent() {
      this.waitCourse.confimAddStudentLoading = true
      if (this.waitCourse.studentId.length <= 0) {
        this.waitCourse.confimAddStudentLoading = false
        this.waitCourseDialog = false
        return
      }
      addCourseStudent({
        ids: this.waitCourse.studentId.join(','),
        courseId: this.upCourse.currentRow.courseId,
        courseName: this.upCourse.currentRow.courseName,
        setMealId: this.upCourse.setMealId,
        setMealName: this.upCourse.scheduleCourseName,
        scheduleCourseId: this.upCourse.currentRow.id,
        scheduleCourseName: this.upCourse.currentRow.scheduleCourseName,
        businessId: this.$store.getters.businessId
      })
        .then(res => {
          this.$message({
            message: '添加成功',
            type: 'success'
          })
          this.getStudent(this.upCourse.currentRow)
          this.waitCourse.confimAddStudentLoading = false
          this.waitCourseDialog = false
        })
        .finally(() => {
          this.$refs.waitCourseTable.clearSelection()
        })
    },
    // 关闭添加学生到套餐dialog
    closeWaitCourseDialog() {
      this.$refs.waitCourseTable.clearSelection()
      this.waitCourse.page = 1
      this.waitCourse.pageSize = 10
    },
    // 上课已排课学生表格分页
    handleSizeWaitCourseChange(val) {
      this.waitCourse.pageSize = val
      this.getSecStudent()
    },
    handleWaitCourseChange(val) {
      this.waitCourse.page = val
      this.getSecStudent()
    },

    // 删除
    handleDelete(index, row) {
      if (row.notScheduled <= 0 && row.scheduled <= 0) {
        this.$confirm('班级删除则不可恢复，确认删除吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            deleteById({
              id: row.id
            }).then(res => {
              this.$message({
                type: 'success',
                message: '删除成功!'
              })
              this.getCourseList()
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
      } else {
        this.$message.error('有学生正在上课，班级暂时不可删除')
      }
    },
    // 排课
    async handleSchedule(index, row) {
      console.log(row);
      this.upCourse.currentRow = row
      if (row.notScheduled === 0) {
        return this.$message({
          message: '请先添加排课学生',
          type: 'error'
        })
      }
      if (row.type === 1) {
        this.scheduleCourseFrom.valueData = {
          ...row,
          kestime: `每节 ${row.lessonTime} 分 | 共 ${row.lessonCount} 节`,
          teacherName: row.teacherName
        }

        this.scheduleDialog = true
      } else {
        await getByCourseId({ courseId: row.courseId }).then(res => {
          this.upCourseTcOption = res.data
          this.upCourseTcOption.forEach(i => {
            i.label = i.name
            i.value = i.id
          })
        })
        await getScheduleCourseById({ id: row.id }).then(res => {
          this.scheduleCourseFrom.valueData = {
            ...this.scheduleCourseFrom.valueData,
            kestime: '请选择套餐',
            ...res.data
          }
          // this.$set(this.scheduleCourseFrom, 'valueData', { ...res.data })
          this.$forceUpdate()
        })
        this.scheduleDialog = true
      }
    },
    // 排课重置表单
    resetJblForm() {
      this.scheduleDialog = false
      // this.JblForm.resetFields()
    },
    restDate() {
      new Date(new Date())
    },
    // 获取下n周七天日期
    // getWeek(n) {
    //   const week = []
    //   const weekDay = this.scheduleCourseFrom.valueData.startTimes.getDay()
    //   for (let i = 0; i < 7 * n; i++) {
    //     const Stamp = new Date()
    //     const num = 7 - Stamp.getDay() + 1 + i
    //     Stamp.setDate(
    //       this.scheduleCourseFrom.valueData.startTimes.getDate() + num
    //     )
    //     // week[i] = Stamp.getMonth() + 1 + '-' + Stamp.getDate()
    //     week[i] = `${Stamp.getFullYear()}-${Stamp.getMonth() +
    //       1}-${Stamp.getDate()}`
    //     console.log(Stamp.getDay(), num, new Date())
    //     console.log(week,this.scheduleCourseFrom.valueData.startTimes.getDate(),'week');

    //   }
    //   console.log(week,weekDay,'week');
    //   return week
    // },
    getMonday(dd) { // 指定日期的周一
      var week = dd.getDay() // 获取时间的星期数
      var minus = week ? week - 1 : 6
      dd.setDate(dd.getDate() - minus) // 获取minus天前的日期
      var y = dd.getFullYear()
      var m = dd.getMonth() + 1 // 获取月份
      var d = dd.getDate()
      return `${y} - ${m} - ${d}`
    },
    getWeek(n, dd) {
      const weekRange = []
      const d = this.getMonday(dd)
      // const d = this.$options.filters.parseTime(this.scheduleCourseFrom.valueData.startTimes, '{y}-{m}-{d}')
      for (var i = 0; i < 7 * n; i++) {
        const d1 = Date.parse(d.replace(/-/g, '/'))
        let date = new Date(d1)
        date = date.valueOf()
        date = date + i * 24 * 60 * 60 * 1000
        date = new Date(date)
        let mymonth = date.getMonth() + 1
        let myday = date.getDate()
        const myyear = date.getFullYear()
        const year = (myyear > 200) ? myyear : 1900 + myyear
        if (mymonth < 10) { mymonth = '0' + mymonth }
        if (myday < 10) { myday = '0' + myday }
        const outputdate = year + '-' + mymonth + '-' + myday
        weekRange.push(outputdate)
      }
      // console.log(weekRange,'weekRange');
      return weekRange
    },
    cancelSheduleCourseFrom() {
      this.scheduleCourseFormRef.resetFields()
      this.scheduleCourseFrom.valueData.skCount = null
      this.scheduleCourseFrom.valueData.lessonCount = null
      this.scheduleCourseFrom.valueData.setMealIds = null
      this.weekValue = []
      this.dateValue = []
      this.ymValue = []
      this.pkStartTime = []
      this.pkEndTime = []
    },
    // 排课预览提交表单
    onSubmitJbl() {
      let confim = false
      this.scheduleCourseFormRef.validate(valid => {
        if (valid) {
          confim = true
          return
        } else {
          return false
        }
      })
      if (!confim) return
      if (this.scheduleCourseFrom.valueData.paikfs === 1) {
        // 按周排课
        const arr = []
        const agn = Math.ceil(
          this.scheduleCourseFrom.valueData.lessonCount /
            this.scheduleCourseFrom.valueData.skCount
        )
        const dd = Object.assign({}, this.scheduleCourseFrom.valueData)
        const nowTime = dd.startTimes
        const nextWeek = this.getWeek(agn, new Date(dd.startTimes))
        // const nowTime = this.$options.filters.parseTime(new Date(), '{y}')
        for (let i = 0; i < agn; i++) {
          this.dateValue.forEach((j, index) => {
            const start = this.$options.filters.parseTime(j, '{h}:{i}')
            const end = this.$options.filters.parseTime(
              j + this.scheduleCourseFrom.valueData.lessonTime * 60 * 1000,
              '{h}:{i}'
            )
            const week = this.weekOptions.find(
              j => j.value === this.weekValue[index]
            ).label

            arr.push({
              week: nextWeek[this.weekValue[index]],
              start: `${nextWeek[this.weekValue[index] + i * 7]} ${start}`,
              end: `${nextWeek[this.weekValue[index] + i * 7]} ${end}`,
              date: `${
                nextWeek[this.weekValue[index] + i * 7]
              } ${week} ${start}-${end}`
              // date: `${new Date(`${nowTime}-${nextWeek[this.weekValue[index] + i * 7]} ${start}`)}`
            })
            // }
          })
        }
        const sarr = arr.filter(i => {
          return new Date(i.start).valueOf() > nowTime
        })
        this.previewData = sarr.slice(
          0,
          this.scheduleCourseFrom.valueData.lessonCount
        )
        const startTime = []
        const endTime = []
        this.previewData.forEach(i => {
          startTime.push(new Date(i.start).valueOf())
          endTime.push(new Date(i.end).valueOf())
        })
        this.pkStartTime = startTime
        this.pkEndTime = endTime
      } else {
        // 按节排课
        this.ymValue.forEach((i, index) => {
          // 年月日
          const y = this.$options.filters.parseTime(i, '{y}-{m}-{d}')
          const w = new Date(i).getDay()
          // 时分
          const h = this.$options.filters.parseTime(
            this.dateValue[index],
            '{h}:{i}'
          )
          // 结束时间
          const e = this.$options.filters.parseTime(
            this.dateValue[index] +
              this.scheduleCourseFrom.valueData.lessonTime * 60 * 1000,
            '{h}:{i}'
          )
          const ww = ['日', '一', '二', '三', '四', '五', '六']
          this.previewData.push({
            date: `${y} 每周${ww[w]} ${h}-${e}`
          })
          this.pkStartTime.push(new Date(`${y} ${h}`).valueOf())
          this.pkEndTime.push(new Date(`${y} ${e}`).valueOf())
        })
        // console.log(this.pkStartTime, this.pkEndTime, ';;;;;;;;;;;;')
      }
      // console.log(confim, this.previewData, arr, nowTime, startTime, endTime, 'dateValue')
      // 检查是否有重复时间
      // if (isRepeat(this.pkStartTime)) {
      //   this.$message({
      //     message: '排课有重复，请修改重复排课',
      //     type: 'error'
      //   })
      //   return
      // }
      // if (isRepeat(this.pkEndTime)) {
      //   this.$message({
      //     message: '排课有重复，请修改重复排课',
      //     type: 'error'
      //   })
      //   return
      // }
      // 排课预览
      verificationTime({
        startTimes: this.pkStartTime.join(','),
        endTimes: this.pkEndTime.join(','),
        lessonTime: this.scheduleCourseFrom.valueData.lessonTime * 60 * 1000,
        businessId: this.$store.getters.businessId,
        scheduleCourseId: this.upCourse.currentRow.id
      }).then(res => {
        const vArr = res.data
        this.previewData.forEach((i, index) => {
          let v = ''
          switch (vArr[index].conflictType) {
            case 1:
              v = '时间冲突'
              break
            case 2:
              v = '老师冲突'
              break
            default:
              v = '正常'
              break
          }
          this.$set(i, 'status', v)
          this.$set(i, 'studentName', vArr[index].studentName)
        })
        this.previewDialog = true
      })
      // this.scheduleDialog = true
      // console.log(this.previewData, ',,,,,,,,,,,')
    },
    // 取消排课
    restDatePreview() {
      this.previewDialog = false
      this.pkStartTime = []
      this.pkEndTime = []
      this.previewData = []
    },
    // 确认排课
    async confimCourse() {
      const confirm = await this.$confirm(
        '排课后将不可更改排课信息，确认排课吗？',
        '提示',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }
      ).catch(() => {})
      if (!confirm) return
      // console.log(this.upCourse.currentRow)
      // return
      await generateLesson({
        scheduleCourseId: this.upCourse.currentRow.id,
        scheduleCourseName: this.upCourse.currentRow.id.scheduleCourseName,
        setMealId: this.scheduleCourseFrom.valueData.setMealIds,
        startTimes: this.pkStartTime,
        endTimes: this.pkEndTime,
        businessId: this.$store.getters.businessId,
        numbers: this.upCourse.currentRow.type === 1 ? this.upCourse.currentRow.lessonCount : null,
        classHour: this.scheduleCourseFrom.valueData.lessonTime,
        businessName: this.upCourse.currentRow.businessName,
        teachName: this.upCourse.currentRow.teacherName,
        courseId: this.upCourse.currentRow.courseId,
        type: this.upCourse.currentRow.type,
        allCourse: this.scheduleCourseFrom.valueData.setMealIds === '0'
      }).then(res => {
        if (this.scheduleCourseForm.valueData.type=== 1) {
          TDAPP.onEvent('按周排课使用次数')
        }else{
          TDAPP.onEvent('按节排课次数');
        }        
        this.$message({
          type: 'success',
          message: '排课成功'
        })
        this.previewDialog = false
        this.scheduleDialog = false
        this.getCourseList()
      })
    },
    // 新建班级重置表单
    resetAddClassForm() {
      this.JblAddClassForm.resetFields()
    },
    onSubmitAddClassForm() {
      this.JblAddClassForm.validate(valid => {
        if (valid) {
          addscheduleCourse({
            ...this.addClassForm.valueData,
            businessId: this.$store.getters.businessId,
            businessName: this.$store.getters.businessName
          }).then(res => {
            TDAPP.onEvent('新建班级')
            this.$message({
              type: 'success',
              message: '新建成功'
            })
            this.addClassDialog = false
            this.getCourseList()
          })
        } else {
          return false
        }
      })
    },

    // 编辑
    handleEdit(index, row) {
      TDAPP.onEvent('编辑班级')
      this.upCourse.currentRow = row
      this.editForm.valueData = Object.assign({}, row)
      this.editDialog = true
    },
    // 编辑重置表单
    resetEditForm() {
      this.JblEditForm.resetFields()
    },
    onSubmitEditForm() {
      this.JblEditForm.validate(valid => {
        if (valid) {
          updateById({
            lessonTime: this.editForm.valueData.lessonTime,
            lessonCount: this.editForm.valueData.lessonCount,
            teacherName: this.editForm.valueData.teacherName,
            scheduleCourseName: this.editForm.valueData.scheduleCourseName,
            type: this.editForm.valueData.type,
            id: this.editForm.valueData.id,
            courseName: this.editForm.valueData.courseName,
            setMealName: this.editForm.valueData.setMealName
          }).then(res => {
            this.$message.success('修改成功')
            this.getCourseList()
          })
          this.editDialog = false
        } else {
          return false
        }
      })
    },
    addClass() {
      this.addClassDialog = true
    },
    // 主表格分页
    handleSizeChange(val) {
      this.pageSize = val
      this.getCourseList()
    },
    handleCurrentChange(val) {
      this.page = val
      this.getCourseList()
      this.$nextTick(() => {
        this.$refs.courseTable.bodyWrapper.scrollTop = 0
      })
    },
    // 上课学生分页
    handleSizeUpCourseChange(val) {
      this.upCourse.pageSize = val
      this.getStudent(this.upCourse.currentRow)
    },
    handleCurrentUpCourseChange(val) {
      this.upCourse.page = val
      this.getStudent(this.upCourse.currentRow)
    },

    // 计算年龄
    ageFormatter(v) {
      const nowDate = this.$options.filters
        .parseTime(new Date().valueOf(), '{y}-{m}-{d}')
        .split('-')
      const birthday =
        v && this.$options.filters.parseTime(v, '{y}-{m}-{d}').split('-')
      const y = nowDate[0] - birthday[0]
      const m = nowDate[1] - birthday[1]
      const d = nowDate[2] - birthday[2] > 0
      return `${y}岁${d ? m : m - 1}个月`
    },
    // 获取排课列表
    getCourseList() {
      scheduleCourseList({
        currentPage: this.page,
        pageSize: this.pageSize,
        businessId: this.$store.getters.businessId
      })
        .then(res => {
          this.total = res.data.total
          this.courseData = res.data.records
        })
        .catch(() => {})
      // 获取待排课学生数量
      getWaitScheduleNumber({
        businessId: this.$store.getters.businessId,
        status: 1
      }).then(res => {
        this.waitCourseNum = res.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.student {
  display: flex;
  align-items: center;
  font-size: 16px;
  span {
    margin-left: 10px;
    font-size: 18px;
    color: #409eff;
    &:hover {
      transform: scale(1.2);
    }
  }
}
.choose {
  // /deep/.el-dialog__body{
  //   height: 600px;
  //   overflow: hidden;
  //   overflow-y: scroll;
  // }
}
.scheduleDialog {
  /deep/.el-dialog__body {
    height: 600px;
    overflow: hidden;
    overflow-y: scroll;
  }
}
.upCourseRef {
  /deep/.el-select .el-input__inner:focus {
    border-color: #e81f1f;
  }
}
.el-row {
  margin-bottom: 20px;
}
/deep/.el-table .cell {
  display: flex;
  justify-content: center;
}
.img-cover {
  width: 100px;
  height: 100%;
}
.img-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qrcode-img {
  /* width: 100%;
    height: 100%; */
}
</style>
